<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/utilities/xajax/xajax_core/xajax.inc.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/gui/presenter/PresenterCreateBranch.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php';
	
	$debug = FirePHP :: getInstance(true);
	$debug -> setEnabled(true);
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$_SESSION['debug'] = $debug;
	
	$xajax = new xajax(); 
	 
	$xajax -> register(XAJAX_FUNCTION, 'selectBranches');

	$xajax -> processRequest(); 
	 
	$xajax -> configure('javascript URI','../../../utilities/xajax/');
	
	
	
	/**
	 * Method to select branches
	 */
	function selectBranches() {
		$presenterCreateBranch = new PresenterCreateBranch();
			$GLOBALS['debug']->log(' INICIO Funcion que llama al presentador para listar las sucursales');
		$branches = $presenterCreateBranch -> selectBranches();
		$response = new xajaxResponse();
		$response -> assign("title", "innerHTML", 'Sucursales');
		$response -> assign("branches", "innerHTML", $branches);

			$GLOBALS['debug']->log(' FIN Funcion que llama al presentador para listar las sucursales');
		
		return $response;
	}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lista de items</title>
<?php 
	$xajax->printJavascript("../../../utilities/xajax/"); 
?>
<link rel="stylesheet" type="text/css" href="../css/formsStyles.css"/>
</head>
<body>
	<script>
		xajax_selectBranches()
    </script>
	<div id="formsContainer">
        <div id="title"></div><br />
		<div id="subtitle"></div><br />
        <div id="branches"></div>
    </div>
</body>
</html>